class JoinRecordsController < ApplicationController
  def create
    @join_record = JoinRecord.new(join_record_params)
    if @join_record.save
      render_success('申请成功，敬请等待客服联系')
    elsif JoinRecord.find_by(mobile: params[:join_record][:mobile])
      render_fail('此号码已申请过，请耐心等待客服联系')
    else
      render_fail('申请失败，请重新申请')
    end
  end

  private

  def join_record_params
    params.require(:join_record).permit(:name, :mobile, :address, :demand, :job)
  end
end
